import { Breadcrumb, Tabs } from 'antd';
import React, { FC } from 'react';
import { useLocation, useNavigate } from 'react-router-dom';
import { PageContainer } from '@/component/page-container';
// import Basic from './compoent/basic';
import BasicTop from '@/view/student/component/basicTop';
import BasicBody from '@/view/student/component/basicBody';
import styles from './index.less';
import { StuNewStudentSrv } from '@/service/student';
import utils, { getPathRoot } from '@/utils';

const Family = React.lazy(() => import('@/view/student/newStu/family'));
const Log = React.lazy(() => import('@/view/student/newStu/log'));

const Groups: FC = () => {
  const navigator = useNavigate();
  const location = useLocation();
  const [keyInfo, setKeyInfo] = React.useState({});
  const [baseInfo, setBaseInfo] = React.useState({});

  const init = async () => {
    utils.showLoading();
    const r = await StuNewStudentSrv.getKeyInfo(location.state.student_id);
    const rbase = await StuNewStudentSrv.getBaseinfo(location.state.student_id);
    if (r.success) {
      setKeyInfo(r.data);
    }
    if (rbase.success) {
      setBaseInfo(rbase.data);
    }
    utils.hideLoaing(r.success && rbase.success);
  };
  React.useEffect(() => {
    init();
  }, []);
  return (
    <PageContainer
      header={
        <Breadcrumb
          items={[
            {
              title: '新生入学管理',
              onClick: () => {
                navigator(`${getPathRoot()}/newstudent`);
              },
            },
            { title: '信息查看' },
          ]}
        />
      }
    >
      {/* <div className={styles.base_info}>
        <Basic buttonList={[<Button onClick={() => navigator('/employed')}>返回</Button>]} />
      </div> */}
      <div className={styles.change_view}>
        <BasicTop isEdit={false} value={keyInfo} />
        <Tabs
          className={styles.tabs}
          type="card"
          items={[
            {
              label: '基本信息',
              key: '1',
              children: (
                <BasicBody
                  isEdit={false}
                  //isShowStep={false}
                  // buttonList={[
                  //   <Button type="dashed" onClick={() => navigator(-1)}>
                  //     返回
                  //   </Button>,
                  // ]}
                  value={baseInfo}
                  onFinish={undefined}
                />
              ),
            },
            {
              label: '家庭成员信息',
              key: '2',
              children: <Family />,
            },
            // {
            //   label: '变更日志',
            //   key: '3',
            //   children: <Log />,
            // },
          ]}
        />
      </div>
    </PageContainer>
  );
};

export default Groups;
